﻿#region Usings

using System;
using System.Globalization;

#endregion

namespace Yandex.Market.Api.Common
{
    internal static class Utils
    {
        public static bool TryParseYmlBoolean(string str, out bool val)
        {
            val = false;

            if(!string.IsNullOrEmpty(str))
            {
                str = str.Trim().ToLower();
                if(str == "false" || str == "0")
                    return true;
                if(str == "true" || str == "1")
                {
					val = true;
                    return true;
                }
            }

            return false;
        }

        public static bool TryParseYmlDouble(string str, out double doubleValue)
        {
            return double.TryParse(str.Trim(),
                                   NumberStyles.AllowDecimalPoint,
                                   CultureInfo.InvariantCulture,
                                   out doubleValue);
        }

        public static void ArgumentNotNull(object argument, string argumentName)
        {
            if(argument == null)
                throw new ArgumentNullException(argumentName);
        }
    }
}